package atguigu.blockQueue;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.SynchronousQueue;

public class Test2 {

	
	public static void main(String[] args) {
		
		BlockingQueue<String> queue = new SynchronousQueue<>();
		new Thread(()->{
		    try {
		        queue.put("1");
		        queue.put("2");
		        queue.put("3");
		    } catch (InterruptedException e) {
		        e.printStackTrace();
		    }
		},"t1").start();

		new Thread(()->{
		    try {
		        System.out.println(queue.take());
		        System.out.println(queue.take());
		        System.out.println(queue.take());
		    } catch (InterruptedException e) {
		        e.printStackTrace();
		    }
		},"t2").start();
	}
}
